package com.userautentification.dao.imp;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.userautentification.dao.DataAccessLayerException;
import com.userautentification.dao.HibernateFactory;
import com.userautentification.dao.UserDao;
import com.userautentification.entities.User;

public class UserDaoImp extends GenericDaoHibernate<User, Long> implements
		UserDao {

	Log log = LogFactory.getLog(UserDaoImp.class);

	public UserDaoImp() {
		HibernateFactory.buildIfNeeded();
	}

	/**
	 * Insert a new User into the database.
	 * 
	 * @param user
	 */
	public void create(User user) throws DataAccessLayerException {
		super.create(user);
	}

	/**
	 * Delete a detached User from the database.
	 * 
	 * @param user
	 */
	public void delete(User user) throws DataAccessLayerException {
		super.delete(user);
	}

	/**
	 * Find an User by its primary key.
	 * 
	 * @param id
	 * @return
	 */
	public User find(Long id) throws DataAccessLayerException {
		return (User) super.find(User.class,id);
	}

	/**
	 * Updates the state of a detached User.
	 * 
	 * @param user
	 */
	public void update(User user) throws DataAccessLayerException {
		super.update(user);
	}

	/**
	 * Finds all User in the database.
	 * 
	 * @return
	 */
	public List findAll() throws DataAccessLayerException {
		return super.findAll(User.class);
	}

}